﻿using System.Collections;
using System.Collections.Generic;
using VirtualDeveloper.Filters;
using Xunit;

namespace UnitTest
{
    public class FilterTest
    {
        [Fact]
        public void lineskipper_enumerable_test()
        {
            var list = new List<string> {"toto"};

            var enumerable = (IEnumerable)new LineSkipper<string>(list, 1);

            Assert.NotNull(enumerable.GetEnumerator());
        }
        
        [Fact]
        public void round_robin_enumerable_test()
        {
            var list = new List<string> {"toto"};

            var enumerable = (IEnumerable)new RoundRobinEnumerable<string>(list);

            Assert.NotNull(enumerable.GetEnumerator());
        }
        
        [Fact]
        public void test_reset_implementation_for_every_x_enumerator()
        {
            var list = new List<string> { "toto", "titi" };

            var everyXEnumerator = new RoundRobinEnumerator<string>(list);

            everyXEnumerator.MoveNext();
            Assert.Equal("toto", everyXEnumerator.Current);
            everyXEnumerator.Reset();
            everyXEnumerator.MoveNext();
            Assert.Equal("toto", ((IEnumerator)everyXEnumerator).Current);
        }

        [Fact]
        public void test_reset_implementation_for_roundrobin()
        {
            var list = new List<string> { "toto", "titi" };

            var everyXEnumerator = new SkipperEnumerator<string>(list, 1);

            everyXEnumerator.MoveNext();
            Assert.Equal("toto", everyXEnumerator.Current);
            everyXEnumerator.Reset();
            everyXEnumerator.MoveNext();
            Assert.Equal("toto", ((IEnumerator)everyXEnumerator).Current);
        }
    }
}
